﻿<BadHabit_WPFTools:ShapedWindow x:Class="BadHabit.Factory.Views.BacklogItemDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Factory_Core="clr-namespace:BadHabit.Factory;assembly=BadHabit.FactoryCore"    
    xmlns:Microsoft_Toolkit="http://schemas.microsoft.com/wpf/2008/toolkit"
    xmlns:BadHabit_Factory_Controls="clr-namespace:BadHabit.Factory.Controls"
    xmlns:BadHabit_WPFTools="clr-namespace:BadHabit.WPFTools;assembly=BadHabit.WPFTools"        
    xmlns:BadHabit_WPFTools_Converters="clr-namespace:BadHabit.WPFTools.Converters;assembly=BadHabit.WPFTools"
                                
    xmlns:props="clr-namespace:BadHabit.Factory.Windows.Properties"              

    WindowStartupLocation="CenterScreen"
                                
    Loaded="ShapedWindow_Loaded"
    SnapsToDevicePixels="True"                                
    Topmost="False"
    ShowInTaskbar="True"
    Icon="/Images/WindowsIcons/Factory.ico"                                
    Style="{StaticResource NormalWindow}"   
    Title="{Binding Title}"
    Width="750"
    Height="550">
    
    <!--<BadHabit_WPFTools:ShapedWindow.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Undo" Executed="Undo_Executed"/>
        <CommandBinding Command="ApplicationCommands.Save" Executed="Save_Executed"/>
    </BadHabit_WPFTools:ShapedWindow.CommandBindings>-->
    
    <BadHabit_WPFTools:ShapedWindow.Resources>
        <DataTemplate x:Key="BacklogItemCancelReasonTemplate">
            <TextBlock Grid.Column="1" Text="{Binding ., Converter={StaticResource LocalizeConverter}}" HorizontalAlignment="Stretch"/>            
        </DataTemplate>
    </BadHabit_WPFTools:ShapedWindow.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ToolBar Grid.Row="0" HorizontalAlignment="Stretch">
            <Menu>
                <MenuItem
                        x:Name="previousButton"
                    Click="previousButton_Click"
                        Style="{StaticResource ToolBarMenuItem}"                                                        
                        Header="{x:Static props:Resources.Previous}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/LeftArrow.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>
                </MenuItem>

                <MenuItem                           
                    x:Name="nextButton"                                                            
                    Style="{StaticResource ToolBarMenuItem}"
                    Click="nextButton_Click"
                    Header="{x:Static props:Resources.Next}">
                    <MenuItem.Icon>
                        <Image Source="/Images/ToolBar/RightArrow.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>                    
                </MenuItem>

            </Menu>
            
            <Separator/>
            
            <Menu>
                
                <MenuItem                                
                    BadHabit_WPFTools:RoleChecker.RequiredEnableRole="QUALITY_ASSURANCE"                    
                    Click="verifiedButton_Click"
                    Header="{x:Static props:Resources.Verified_now}">
                    <MenuItem.Icon>
                        <Image Source="/Images/BacklogItemStatus/ItemVerified.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>
                    <MenuItem.Style>
                        <Style BasedOn="{StaticResource ToolBarMenuItem}" TargetType="MenuItem" >
                            <Setter Property="Button.Visibility" Value="Collapsed"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding VerifiedDate}" Value="{x:Null}">
                                    <Setter Property="Button.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </MenuItem.Style>
                </MenuItem>

                <MenuItem                                
                    BadHabit_WPFTools:RoleChecker.RequiredEnableRole="PRODUCT_OWNER"                    
                    Click="validadedButton_Click"
                    Header="{x:Static props:Resources.Validated_now}">
                    <MenuItem.Icon>
                        <Image Source="/Images/BacklogItemStatus/ItemValidated.png" Stretch="Uniform" Width="32" Height="32"/>
                    </MenuItem.Icon>
                    <MenuItem.Style>
                        <Style BasedOn="{StaticResource ToolBarMenuItem}" TargetType="MenuItem" >
                            <Setter Property="Button.Visibility" Value="Collapsed"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding ValidatedDate}" Value="{x:Null}">
                                    <Setter Property="Button.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </MenuItem.Style>
                </MenuItem>

            </Menu>

        </ToolBar>

        <TabControl Margin="0,5,0,0" Grid.Row="1">
            <TabItem Header="{x:Static props:Resources.Backlog_Item}">
                <Grid x:Name="itemGrid" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="3" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>


                    <Grid Grid.Row="0" Grid.ColumnSpan="3">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="100"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.Number}"/>
                        <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource Label}" Text="{x:Static props:Resources.Name}"/>
                        <TextBlock Grid.Column="0" Grid.Row="2" Style="{StaticResource Label}" Text="{x:Static props:Resources.Business_Value}"/>
                        <TextBlock Grid.Column="2" Grid.Row="2" Style="{StaticResource Label}" Text="{x:Static props:Resources.Size}" />
                        <TextBlock Grid.Column="0" Grid.Row="3" Style="{StaticResource Label}" Text="{x:Static props:Resources.Group}"/>


                        <TextBox Grid.Column="1" Grid.Row="0" Style="{StaticResource LabelInfo}" Text="{Binding BacklogItemNumber}" />

                        <CheckBox Grid.Column="3" Grid.Row="0" IsChecked="{Binding IsBugCorrection}" HorizontalAlignment="Right"
                      BadHabit_WPFTools:RoleChecker.RequiredEnableRole="SCRUM_MASTER">
                            <TextBlock VerticalAlignment="Center" Text="{x:Static props:Resources.Bug_Correction_Item}">
                    
                    <Image Source="/Images/TaskType/16x16/DEVELOPING_BUG.png" Width="16" Height="16" Stretch="Uniform"/>
                            </TextBlock>
                        </CheckBox>

                        <TextBox Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="1"
                     Style="{StaticResource FormTextBox}"
                     MaxLength="150"
                     Text="{Binding Title}" HorizontalAlignment="Stretch" FontSize="{StaticResource NeedToSeeFontSize}"
                     BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"/>


                        <TextBox Grid.Column="1" Grid.Row="2"
                     Style="{StaticResource FormTextBox}"
                     Text="{Binding BusinessValue}" HorizontalAlignment="Stretch"
                     BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"/>

                        <BadHabit_WPFTools:ComboBox Grid.Column="3" Grid.ColumnSpan="2" Grid.Row="2"
                                        HorizontalAlignment="Stretch"                                           
                                        Style="{StaticResource SizeComboBox}"                                            
                                        ItemsSource="{Binding Source={StaticResource BacklogItemSizeList}}"
                                        BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"
                                        >
                            <BadHabit_WPFTools:ComboBox.GroupStyle>
                                <GroupStyle HeaderTemplate="{StaticResource ComboBoxGroupHeaderTemplate}"/>
                            </BadHabit_WPFTools:ComboBox.GroupStyle>
                        </BadHabit_WPFTools:ComboBox>


                        <TextBox Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="3"
                     Style="{StaticResource FormTextBox}"
                                 
                     Text="{Binding GroupName}" HorizontalAlignment="Stretch"
                     BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"/>



                    </Grid>

                    <GroupBox Grid.Row="1" Grid.ColumnSpan="3" Header="{x:Static props:Resources.Status}">
                        <Grid VerticalAlignment="Stretch">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>


                            <BadHabit_WPFTools:ComboBox           
                                    x:Name="statusComboBox"
                                    Grid.Column="0"
                                    MinWidth="150"
                                    Style="{StaticResource FormComboBox}"                                    
                                    SelectedValue="{Binding Status, Converter={StaticResource EnumConverter}, ConverterParameter={x:Type Factory_Core:BacklogItemStatus} }"   
                                    ItemsSource="{Binding Source={StaticResource BacklogItemStatusList}}"                                    
                                    SelectedItemTemplate="{StaticResource BacklogItemStatusTemplate}"
                                    ItemTemplate="{StaticResource BacklogItemStatusTemplate}"
                                    BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"/>

                            <TextBlock Grid.Column="1"  Style="{StaticResource Label}" Text="{x:Static props:Resources.Started_at}"/>

                            <Microsoft_Toolkit:DatePicker
                                Grid.Column="2"
                                BadHabit_WPFTools:RoleChecker.RequiredEnableRole="SCRUM_MASTER"
                                SelectedDate="{Binding StartDate}"/>

                            <TextBlock Grid.Column="3" Style="{StaticResource Label}" Text="{x:Static props:Resources.Finished_at}"/>

                            <Microsoft_Toolkit:DatePicker
                                x:Name="finishDateDatePicker"
                                Grid.Column="4" 
                                BadHabit_WPFTools:RoleChecker.RequiredEnableRole="SCRUM_MASTER"
                                SelectedDate="{Binding FinishDate}"/>

                            <TextBlock Grid.Column="0" Grid.Row="1" Text="{x:Static props:Resources.Cancel_reason}">
                    <TextBlock.Style>
                        <Style BasedOn="{StaticResource Label}" TargetType="TextBlock">
                            <Setter Property="TextBlock.Visibility" Value="Collapsed"/>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Status}" Value="3">
                                    <Setter Property="TextBlock.Visibility" Value="Visible"/>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBlock.Style>
                            </TextBlock>
                            <BadHabit_WPFTools:ComboBox                                               
                                    Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="4"
                                    MinWidth="150"                    
                                    ItemTemplate="{StaticResource BacklogItemCancelReasonTemplate}"
                                    SelectedItemTemplate="{StaticResource BacklogItemCancelReasonTemplate}"
                                    SelectedValue="{Binding CancelReason, Converter={StaticResource EnumConverter}, ConverterParameter={x:Type Factory_Core:BacklogItemCancelReasons} }"   
                                    ItemsSource="{Binding Source={StaticResource BacklogItemCancelReasonList}}"                                                                        
                                    BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER">
                                <BadHabit_WPFTools:ComboBox.Style>
                                    <Style BasedOn="{StaticResource FormComboBox}" TargetType="BadHabit_WPFTools:ComboBox">
                                        <Setter Property="ComboBox.Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Status}" Value="3">
                                                <Setter Property="ComboBox.Visibility" Value="Visible"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </BadHabit_WPFTools:ComboBox.Style>
                            </BadHabit_WPFTools:ComboBox>

                        </Grid>

                    </GroupBox>
                    <GroupBox Grid.Row="2" Grid.Column="0" >
                        <GroupBox.Header>
                            <TextBlock FontSize="16" Foreground="#0050B0">
                    <Image Source="/Images/ToolBar/plan.png" Width="16" Height="16" Stretch="Uniform"/>
                    <TextBlock Text="{x:Static props:Resources.Accepted_Planned}"/>                    
                </TextBlock>
                        </GroupBox.Header>
                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.When}"  />
                            <TextBox
                                x:Name="acceptedDateTextBox"
                                Grid.Column="1" Grid.Row="0" Style="{StaticResource LabelInfo}" Text="{Binding AcceptedDate}" />
                            <TextBox Grid.Column="1" Grid.Row="0" Text="{x:Static props:Resources.Not_yet}" >
                                <TextBox.Style>
                                    <Style BasedOn="{StaticResource LabelInfo}" TargetType="TextBox">
                                        <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding AcceptedDate}" Value="{x:Null}">
                                                <Setter Property="TextBox.Visibility" Value="Visible"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBox.Style>
                            </TextBox>
                        </Grid>
                    </GroupBox>
                    <GroupBox Grid.Row="2" Grid.Column="1">
                        <GroupBox.Header>
                            <TextBlock FontSize="16" Foreground="#0050B0">
                    <Image Source="/Images/BacklogItemStatus/ItemVerified.png" Width="16" Height="16" Stretch="Uniform"/>
                    <TextBlock Text="{x:Static props:Resources.Q_A_Verification}"/>                    
                </TextBlock>
                        </GroupBox.Header>

                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="*"/>                            
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.When}"  />
                            <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource Label}" Text="{x:Static props:Resources.By}" />
                            
                            <TextBox Grid.Column="1" Grid.Row="0" Style="{StaticResource LabelInfo}" Text="{Binding VerifiedDate}" />
                            <TextBox Grid.Column="1" Grid.Row="0" Text="{x:Static props:Resources.Not_yet}" >
                                <TextBox.Style>
                                    <Style BasedOn="{StaticResource LabelInfo}" TargetType="TextBox">
                                        <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding VerifiedDate}" Value="{x:Null}">
                                                <Setter Property="TextBox.Visibility" Value="Visible"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBox.Style>
                            </TextBox>
                            <TextBox Grid.Column="1" Grid.Row="1" Style="{StaticResource LabelInfo}" Text="{Binding VerifiedBy}" />
                        </Grid>
                    </GroupBox>
                    <GroupBox Grid.Row="2" Grid.Column="2">
                        <GroupBox.Header>
                            <TextBlock FontSize="16" Foreground="#0050B0">
                    <Image Source="/Images/BacklogItemStatus/ItemValidated.png" Width="16" Height="16" Stretch="Uniform"/>
                    <TextBlock Text="{x:Static props:Resources.Client_Validation}"/>                    
                </TextBlock>
                        </GroupBox.Header>

                        <Grid HorizontalAlignment="Stretch" VerticalAlignment="Top">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="*"/>                                
                            </Grid.RowDefinitions>
                            <TextBlock Grid.Column="0" Grid.Row="0" Style="{StaticResource Label}" Text="{x:Static props:Resources.When}" />
                            <TextBlock Grid.Column="0" Grid.Row="1" Style="{StaticResource Label}" Text="{x:Static props:Resources.By}"/>
                            
                            <TextBox Grid.Column="1" Grid.Row="0" Style="{StaticResource LabelInfo}" Text="{Binding ValidatedDate}" />
                            <TextBox Grid.Column="1" Grid.Row="0" Text="{x:Static props:Resources.Not_yet}" >
                                <TextBox.Style>
                                    <Style BasedOn="{StaticResource LabelInfo}" TargetType="TextBox">
                                        <Setter Property="TextBox.Visibility" Value="Collapsed"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ValidatedDate}" Value="{x:Null}">
                                                <Setter Property="TextBox.Visibility" Value="Visible"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </TextBox.Style>
                            </TextBox>
                            <TextBox Grid.Column="1" Grid.Row="1" Style="{StaticResource LabelInfo}" Text="{Binding ValidatedBy}" />
                        </Grid>

                    </GroupBox>

                    <GroupBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" Header="{x:Static props:Resources.More_Details}">
                        <TextBox                 
                    Style="{StaticResource FormTextBox}"
                    Text="{Binding Description}"
                    MaxLength="500"
                    AcceptsReturn="True"
                    TextWrapping="Wrap"
                    VerticalAlignment="Stretch"
                    FontSize="{StaticResource NeedToSeeFontSize}"
                    
                    VerticalScrollBarVisibility="Auto"
                    BadHabit_WPFTools:RoleChecker.RequiredEditRole="SCRUM_MASTER"/>
                    </GroupBox>





                </Grid>
            </TabItem>
            <TabItem Header="{x:Static props:Resources.Artifacts_Materials}">
                <Border Style="{StaticResource RoundBorder}">
                    <BadHabit_Factory_Controls:ArtifactListBox
                x:Name="artifactListBox"
                ScrollViewer.VerticalScrollBarVisibility="Auto"     
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"                        
                HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                Background="Transparent"/>
                </Border>
            </TabItem>
        </TabControl>

    </Grid>

    


</BadHabit_WPFTools:ShapedWindow>
